/*******************************************************************************
 * Copyright (c) 2008, 2009 Fabio Mauro - Alberto Terraneo.
 * Permission is granted to copy, distribute and/or modify this document
 * under the terms of the GNU Free Documentation License, Version 1.2
 * or any later version published by the Free Software Foundation.
 *     
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied 
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 * See the GNU Free Documentation License for more details.
 *     
 * You should have received a copy of the GNU Free Documentation 
 * License along with this distribution; if not, send a email to authors:
 * aterraneo <at> users.sourceforge.net
 * bigmoby09 <at> users.sourceforge.net
 *******************************************************************************/
/**
 * Common base interface per persistent entity, with CRUD functionality:
 */
package it.blueocean.acanto.dao.common;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.Criterion;

/**
 * @author Fabio Mauro
 * 
 */
public interface IGenericDao<T, KeyType extends Serializable>
{
    T findById(KeyType id, boolean lock);

    List<T> findByExample(T exampleInstance, List<String> excludeProperty);
    
    List<T> findByQuery(String hqlQuery, Object value);
    
    List<T> findByCriteria(List<Criterion> criterion);
    
    List<T> findAll();
    
    List<T> findAll(String... eagerAttribute);
    
    List<T> paginatedResult(int start, int limit);

    T makePersistent(T entity);

    void makeTransient(T entity);
    
    void flush();

    void clear();
}
